<%@ page import="inspur.dao.UserDao" %>
<%@ page import="inspur.entity.CookieTokenObject" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/10/22
  Time: 19:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="config.jsp"%>
<html>
<head>
    <title><%=webTitle%></title>
    <meta name="Keywords" content="<%=keywords%>">
    <meta name="Description" content="<%=Description%>">
    <link rel="stylesheet" href="css/style.css"><!--css通用样式表-->
    <style>
        *{
            font-family:Microsoft YaHei;
            font-size:16px;
            color:#666666;
        }
        summary{
            font-family:Microsoft YaHei;
            font-size:16px;
            color:#666666;
        }
    </style>
    <%
        String error="";
        int type=2;
        User user=null;
        user= UserDao.isLogin(request);//从cookie中获取登录状态
        if (user==null){//尚未登录
            // 重定向，不允许游客访问
            response.sendRedirect(request.getContextPath() + "login.jsp");
            return;
        }else {//已经登录
            String url=request.getParameter("user");//从URL中获取访问状态
            if (url==null){
                url=user.getId();
            }
            //是否访问的是自己的账户
            if (url.equals(user.getId())){
                //是自己的账户，就正常显示
            }else {
                //不是自己的账户,判断是否为管理员
                if (UserDao.isAdmin(user.getIdentity() )){
                    //是管理员
                    User tempuser=UserDao.getUserByUserId(url);
                    if (tempuser!=null){
                        user=tempuser;
                    }else {
                        error="url参数错误,数据库中可能不存在userid="+url+"的记录！！";
                    }
                }else {
                    // 重定向，不允许游客访问
                    response.sendRedirect(request.getContextPath() + "login.jsp");
                    return;//终止程序
                }
            }
        }
    %>
</head>
<body>
    <div align="center">
        <%@include file="component/top.jsp"%><!---顶栏-->
        <%@include file="component/checkBox.jsp"%><!--搜索框-->
        <p><%=error%></p><!--输出错误信息-->
        <div style="width: 1000px;text-align: left">
            <!--用户基本设置-->
            <details open="open">
                <p> <summary>用户基本设置：</summary></p>
            <form action="" method="post">
                <table>
                    <tr>
                        <td>头像：</td>
                        <td>无</td>
                    </tr>
                    <tr>
                        <td>用户ID:</td>
                        <td><input type="text"value="<%=user.getId()%>" readonly="readonly">警告：只读，不可更改</td>
                    </tr>
                    <tr>
                        <td>用户昵称</td>
                        <td><input type="text"value="<%=user.getUsername()%>"></td>
                    </tr>
                    <tr>
                        <td>登陆密码：</td>
                        <td><input type="text"value="<%=type==2?user.getPassword():""%>"></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type="reset" value="重置填写" ><input type="submit" value="更新信息"></td>
                    </tr>
                </table>
            </form>
            </details>
            <details>
                <summary>站内信息设置</summary>
                <form action="" method="post">
                    <table>
                        <tr>
                            <td>所在团队：</td>
                            <td><input type="text" value="<%=user.getGroup()%>"> </td>
                        </tr>
                        <tr>
                            <td>所在组织：</td>
                            <td><input type="text" value="<%=user.getOrg()%>"> </td>
                        </tr>
                        <tr>
                            <td>站内身份：</td>
                            <td><input type="text" value="<%=user.getIdentity()%>"> </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td><input type="reset" value="重置填写" ><input type="submit" value="更新信息"></td>
                        </tr>
                    </table>
                </form>
            </details>
            <details>
                <summary>个人隐私设置</summary>
                <form action="" method="post">
                    <table>
                        <tr>
                            <td>联系电话：</td>
                            <td><input type="text" value="<%=user.getTell()%>"> </td>
                        </tr>
                        <tr>
                            <td>联系QQ：</td>
                            <td><input type="text" value="<%=user.getQq()%>"> </td>
                        </tr>
                        <tr>
                            <td>联系微信：</td>
                            <td><input type="text" value="<%=user.getVx()%>"> </td>
                        </tr>
                        <tr>
                            <td>所在省份代码：</td>
                            <td><input type="text" value="<%=user.getProvince()%>"><a href="">帮助我填写</a> </td>
                        </tr>
                        <tr>
                            <td>所在城市代码：</td>
                            <td><input type="text" value="<%=user.getCity()%>"> </td>
                        </tr>
                        <tr>
                            <td>城市区域代码：</td>
                            <td><input type="text" value="<%=user.getArea()%>"> </td>
                        </tr>
                        <tr>
                            <td>详细地址：</td>
                            <td><input type="text" value="<%=user.getAddress()%>"> </td>
                        </tr>
                        <tr>
                            <td>电子邮箱：</td>
                            <td><input type="text" value="<%=user.getEmail()%>"> </td>
                        </tr>
                        <tr>
                            <td>个人介绍：</td>
                            <td><textarea style="width: 500px;height: 200px"><%=user.getIntroduction()%></textarea></td>
                        </tr>
                    <tr>
                        <td></td>
                        <td><input type="reset" value="重置填写" ><input type="submit" value="更新信息"></td>
                    </tr>
                    </table>
                </form>
            </details>
            <details>
                <summary>安全设置</summary>
                <a href="signout.jsp">退出登录</a><br>
                <a href="help.jsp">安全协助</a>

            </details>
        </div>
    </div>
</body>
</html>
